package cn.itcast.mybatis.demo3.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import cn.itcast.mybatis.demo3.UserDao;
import cn.itcast.mybatis.pojo.User;

public class UserDaoImpl extends SqlSessionDaoSupport implements UserDao {

	
	
	@Override
	public User getUserById(int id) {
		SqlSession sqlSession = getSqlSession();
		User user = sqlSession.selectOne("test.getUserById", id);
		return user;
	}


	@Override
	public List<User> getUserByAddress(String string) {
		SqlSession sqlSession = getSqlSession();
		List<User> selectList = sqlSession.selectList("test.getUserByAddress", string);
		return selectList;
	}


	@Override
	public void deleteUser(int i) {
		SqlSession sqlSession = getSqlSession();
		sqlSession.delete("test.deleteUser", i);
		sqlSession.commit();
	}

	
	
	

}
